Skip to content

Conversation

@nh2
Copy link
Member

@nh2 nh2 commented Feb 8, 2017

Consider ln (or any other Unix tool):

$ ln -s file1 file2
$ ls -l file2
lrwxrwxrwx 1 niklas niklas 5 Feb  8 03:09 file2 -> file1
$ ln -s file1 file2
ln: failed to create symbolic link 'file2': File exists

The file name mentioned in the error ("link2") is the one
that could not be created, not the content of the pointer.

createSymbolicLink got this wrong so far, it would print

file1: createSymbolicLink: already exists (File exists)

which is wrong, this file doesn't already exist.

This commit fixes it.

Consider `ln` (or any other Unix tool):

    $ ln -s file1 file2
    $ ls -l file2
    lrwxrwxrwx 1 niklas niklas 5 Feb  8 03:09 file2 -> file1
    $ ln -s file1 file2
    ln: failed to create symbolic link 'file2': File exists

The file name mentioned in the error ("link2") is the one
that *could not be created*, not the content of the pointer.

`createSymbolicLink` got this wrong so far, it would print

    file1: createSymbolicLink: already exists (File exists)

which is wrong, this file doesn't already exist.

This commit fixes it.
@glguy
Copy link
Member

glguy commented Feb 8, 2017

This seems like a reasonable change. Consulting the man page for symlink(2) on macOS I note that it's only in the case of EFAULT that file1 might be the relevant filename: [EFAULT] Path1 or path2 points outside the process's allocated address space. In all other cases the error message pertains to path2.

@nh2
Copy link
Member Author

nh2 commented Feb 9, 2017

points outside the process's allocated address space

@glguy do you know what this means in the context of file systems? I'm trying to trigger this, but don't know how.

@nh2
Copy link
Member Author

nh2 commented Feb 9, 2017

@glguy I just wanted to implement a check or EFAULT to address this, but then noticed that indeed it says Path1 or path2 so we can't really know which one it is.

So EFAULT seems to be unbiases about whether to include the first or second one in the message.

@rwbarton
Copy link
Contributor

rwbarton commented Feb 9, 2017

EFAULT means that one of the char *s you passed points to a memory address that isn't mapped in the application. For example, it is likely to happen if you pass a totally random char * value to symlink(). You'll have some trouble triggering it via createSymbolicLink; I wouldn't worry about the error message.

@nh2
Copy link
Member Author

nh2 commented Feb 10, 2017

Ah, that makes sense, thanks for the explanation.

@glguy glguy merged commit 312ed21 into haskell:master Feb 14, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants